@use '@/styles/vars.scss' as vars;

* {
  padding: 0;
  margin: 0;
}

html,
body {
  height: 100%;
}

#root {
  height: 100%;
  overflow: hidden;
}

/** ================================ 覆盖antd pro样式开始 ================================ */
.ant-pro-page-container-children-container-no-header {
  padding-block-start: 0 !important;
}

.ant-pro-page-container-children-container {
  padding-block-end: 0 !important;
  padding-inline: 0 !important;
}

/** ================================ 覆盖antdpro样式结束 ================================ */

/** ================================ 固定Table表头背景色 ================================ */
/* 固定antd表格表头背景色为通用灰色，不随主题切换而改变 */
.ant-table-wrapper .ant-table-thead>tr>th,
.ant-table-wrapper .ant-table-thead>tr>td {
  background-color: #fafafa !important;
}

/* 确保表头在不同状态下也保持固定的背景色 */
.ant-table-wrapper .ant-table-thead>tr>th.ant-table-column-sort,
.ant-table-wrapper .ant-table-thead>tr>th.ant-table-cell-row-hover,
.ant-table-wrapper .ant-table-thead>tr>th:hover {
  background-color: #fafafa !important;
}

.w-full {
  width: 100% !important;
}

.h-full {
  height: 100% !important;
}

.flex {
  display: flex;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.align-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.space-between {
  justify-content: space-between;
}

.grow {
  flex-grow: 1;
}

.flex-row-reverse {
  flex-direction: row-reverse;
}

/** 行高样式10-100px */
@for $i from 10 through 100 {
  .line-height-#{$i} {
    line-height: #{$i}px;
  }
}

/** 底部间距10-100px */
@for $i from 1 through 10 {
  .mb-#{$i} {
    margin-bottom: #{$i * 10}px;
  }
}

/** 顶部间距10-100px */
@for $i from 1 through 10 {
  .mt-#{$i} {
    margin-top: #{$i * 10}px;
  }
}

/** 左侧间距1-100px */
@for $i from 1 through 100 {
  .ml-#{$i} {
    margin-left: #{$i}px;
  }
}

/** 右侧间距1-100px */
@for $i from 1 through 100 {
  .mr-#{$i} {
    margin-right: #{$i}px;
  }
}

.border-none {
  border: none;
}

.fancyx-table-wrapper {
  .ant-table-cell .ant-btn-link {
    padding-left: 0 !important;
    padding-right: 0 !important;
    gap: 0 !important;
  }

  .right-operation-toolbar {
    button {
      padding: 0 !important;
    }
  }
}

.fancyx-layout {
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;

  .fancyx-sidebar {
    min-height: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: vars.$bg-base;
  }

  // 侧边栏菜单内容容器，允许滚动
  .sidebar-content {
    flex: 1;
    min-height: 0; // 确保在flex容器中正确收缩
    overflow-y: auto; // 基础滚动功能

    // 关键：使用overlay而不是auto，滚动条不会占用内容空间
    overflow-y: overlay;

    // 浅色主题滚动条样式 - 不占用空间的悬浮滚动条
    &::-webkit-scrollbar {
      width: 5px; // 适中宽度确保可见
      height: 5px; // 水平滚动条高度
    }

    // 完全隐藏滚动条轨道
    &::-webkit-scrollbar-track {
      background: transparent; // 完全透明的轨道
      border-radius: 3px; // 圆角
    }

    // 滚动条滑块样式 - 保持可见性
    &::-webkit-scrollbar-thumb {
      background: rgba(0, 0, 0, 0.25); // 增加透明度使滑块更明显
      border-radius: 3px; // 圆角
      transition: background-color 0.2s ease;

      // 滑块悬浮效果增强
      &:hover {
        background: rgba(0, 0, 0, 0.35);
      }
    }

    // 隐藏所有滚动条按钮和边角
    &::-webkit-scrollbar-button,
    &::-webkit-scrollbar-corner {
      display: none; // 完全隐藏
    }

    // Firefox样式优化
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent; // 只显示滑块
  }

  .ant-layout-sider {
    min-height: 100%;
    background-color: vars.$bg-base;
  }

  //侧边栏标题
  .sidebar-header {
    height: 50px; // 严格限定高度
    padding: 0 20px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: vars.$shadow-sm;
    flex-shrink: 0; // 防止标题被压缩

    // 主题波纹装饰（跟随当前主题颜色变化）
    &::after {
      content: '';
      position: absolute;
      right: -30px;
      top: -30px;
      width: 80px;
      height: 80px;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.05) 100%);
      border-radius: 50%;
      transition: transform 0.3s ease;
    }

    h2 {
      margin: 0;
      color: white;
      font-size: 18px;
      font-weight: 500;
      display: flex;
      align-items: center;
      width: 100%;
      white-space: nowrap;

      .header-icon {
        font-size: 22px;
        margin-right: 10px;
        flex-shrink: 0;
      }

      .header-icon-center {
        margin: 0 auto;
      }
    }

    // 悬停动画
    &:hover::after {
      transform: scale(1.1);
      transition: transform 0.3s ease;
    }
  }

  /* 暗色侧边栏样式 */
  .dark-sidebar {
    background-color: #1f1f1f;
    transition: background-color 0.3s ease;
    height: 100%;
  }

  /* 确保暗色侧边栏在内容滚动时完全填充 */
  .ant-layout-sider.dark-sidebar {
    background-color: #1f1f1f;
    overflow: hidden;
  }

  .dark-sidebar .sidebar-header {
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.8), rgba(40, 40, 40, 0.8));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .dark-sidebar h2 {
    color: #e0e0e0;
    /* 细微色差效果 */
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.1);
  }

  .dark-sidebar .header-icon {
    background: linear-gradient(135deg, var(--primary-color, #177ddc), #3b96e8);
    box-shadow: 0 2px 12px rgba(23, 125, 220, 0.4);
  }

  .dark-sidebar .sidebar-content {
    background-color: #1f1f1f;
    overflow-y: auto; // 基础滚动功能

    // 关键：使用overlay而不是auto，滚动条不会占用内容空间
    overflow-y: overlay;

    // 暗色主题滚动条样式 - 不占用空间的悬浮滚动条
    &::-webkit-scrollbar {
      width: 5px; // 适中宽度确保可见
      height: 5px; // 水平滚动条高度
    }

    // 完全隐藏滚动条轨道
    &::-webkit-scrollbar-track {
      background: transparent; // 完全透明的轨道
      border-radius: 3px; // 圆角
    }

    // 滚动条滑块样式 - 保持可见性
    &::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, 0.25); // 增加透明度使滑块更明显
      border-radius: 3px; // 圆角
      transition: background-color 0.2s ease;

      // 滑块悬浮效果增强
      &:hover {
        background: rgba(255, 255, 255, 0.35);
      }
    }

    // 隐藏所有滚动条按钮和边角
    &::-webkit-scrollbar-button,
    &::-webkit-scrollbar-corner {
      display: none; // 完全隐藏
    }

    // Firefox样式优化
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent; // 只显示滑块
  }

  .dark-sidebar .ant-menu {
    background-color: transparent;
  }

  /* 菜单项基本样式 - 增加亮度 */
  .dark-sidebar .ant-menu-item,
  .dark-sidebar .ant-menu-submenu-title {
    color: #d0d0d0;
    transition: color 0.2s ease;
  }

  /* 菜单项悬浮效果 - 文字变亮，添加轻微透明浅色背景 */
  .dark-sidebar .ant-menu-item:hover,
  .dark-sidebar .ant-menu-submenu-title:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
  }

  /* 确保所有可能的悬浮状态都有轻微透明浅色背景且文字更亮 */
  .dark-sidebar .ant-menu-item:hover,
  .dark-sidebar .ant-menu-submenu:hover>.ant-menu-submenu-title,
  .dark-sidebar .ant-menu-submenu-title:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
  }

  /* 选中菜单项样式 - 加深背景色 */
  .dark-sidebar .ant-menu-item-selected {
    color: var(--primary-color, #177ddc) !important;
    background-color: rgba(23, 125, 220, 0.2) !important;
  }

  /* 激活菜单项样式 - 仅文字变色 */
  .dark-sidebar .ant-menu-item-active,
  .dark-sidebar .ant-menu-submenu-active {
    color: var(--primary-color, #177ddc);
    background-color: transparent;
  }

  /* 确保子菜单标题颜色与菜单项一致 */
  .dark-sidebar .ant-menu-submenu-title {
    color: #d0d0d0 !important;
  }

  /* 展开的子菜单标题颜色 */
  .dark-sidebar .ant-menu-submenu-open>.ant-menu-submenu-title {
    color: #ffffff !important;
  }

  .fancyx-navbar {
    height: 50px;
    border-bottom: 1px solid vars.$border-color-light;
    background-color: vars.$bg-base;
    flex-shrink: 0;

    button.ant-btn {
      height: 50px !important;
      border-radius: 0 !important;
    }

    .fancyx-navbar-breadcrumb-wrapper {
      nav {
        line-height: 50px !important;
      }
    }

    .fancyx-navbar-right-wrapper {
      button.ant-btn {
        padding-left: 10px !important;
        padding-right: 10px !important;
      }
    }
  }

  .fancyx-tabs {
    height: 42px;
    background-color: vars.$bg-base;
    flex-shrink: 0;
  }

  /* 调整内部布局容器为flex列布局 */
  .ant-layout>.ant-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  /* 内容区域占据剩余空间并可滚动 */
  .ant-layout-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
  }

  /* 确保暗色侧边栏正确显示 */
  .ant-layout-sider.dark-sidebar {
    background-color: #1f1f1f;
  }

  main {
    padding: 10px;
    background-color: vars.$bg-light;
  }
}

// 菜单项悬停动画
.ant-menu-item {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    background: vars.$primary-light !important;

    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 3px;
      background: vars.$primary-color;
    }
  }
}

// 选中状态
.ant-menu-item-selected {
  background: vars.$primary-lighter !important;
  color: vars.$primary-color !important;
  font-weight: 500;
}

.ant-btn-primary {
  box-shadow: 0 2px 6px vars.$shadow-primary;
  transition: all 0.3s;

  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px vars.$shadow-primary-hover;
  }

  &:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px vars.$shadow-primary-active;
  }
}

.icon-info:hover {
  color: vars.$text-primary;
}